package everydayGrade.t5;

import java.util.Arrays;

/**
 * @Author: Siantar
 * @Date: 2023-07-18-15:07
 * @Description: 1.0
 */
public class T2090 {
    public int[] getAverages(int[] nums, int k) {
        int n = nums.length, m = 2 * k + 1;
        int[] res = new int[n];
        if (m > n) {
            Arrays.fill(res, -1);
            return res;
        }
        long sum = nums[k];
        for (int i = 0; i < k; i++) {
            sum += nums[i];
            sum += nums[k + i + 1];
            res[i] = -1;
            res[n - i - 1] = -1;
        }
        res[k] = (int)(sum / m);
        for (int i = k + 1; i < n - k; i++) {
            sum -= nums[i - k - 1];
            sum += nums[i + k];
            System.out.println(sum);
            res[i] = (int)(sum / m);
        }
        return res;
    }
}
